<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Connection Monitor</title>
<script src="servicemonitor.swf" type="application/x-shockwave-flash" />
<script type="text/javascript" src="AIRAliases.js"></script>
<script>
// DEFINE The Variable that will hold the URLMonitor
var monitor;

function onLoad() {
	
	// URLRequest that the Monitor Will Check
	var request = new air.URLRequest( "http://www.davidtucker.net/index.php" );
	// Checks Only the Headers - Not the Full Page
	request.method = "HEAD";
	
	// Create the URL Monitor and Pass it the URLRequest
	monitor = new air.URLMonitor( request );
	// Create the Event Listener that Will Be Fired When Connection Changes
	monitor.addEventListener( air.StatusEvent.STATUS, doStatus );
	// Start the URLMonitor
	monitor.start();
	
}

function doStatus( event )  {

	// Grab the Image that Will Display the Status
	var elem = document.statusImage;
	
	// If Connection is Available
	if(monitor.available == true) {
	
		// Display GreenLight Image and Enable Button
		elem.src = "greenLight.png";
		document.searchForm.searchButton.disabled = false;
	
	// If Connection is Not Available
	} else {
	
		// Display RedLight Image and Disable Button
		elem.src = "redLight.png";
		document.searchForm.searchButton.disabled = true;
		
	}

}

function searchWeb() {

	// Go to Google Page once Button is Clicked
	var req = new air.URLRequest("http://www.google.com/search?q=" + document.searchForm.searchTerms.value);
	air.navigateToURL(req);

}

window.onload = onLoad;
</script>

<style type="text/css">
<!--
body {
	padding: 10px;
}
.fItem {
	float: left;
}
.fItem img {
	padding: 7px;
}
-->
</style>
</head>
<body>
<div id="main">
	<img src="google.png" />
	<form name="searchForm" onsubmit="searchWeb()">
	<div class="fItem"><input id="searchTerms" type="text" name="searchTerms" /></div>
	<div class="fItem"><input name="searchButton" type="submit" value="Search" /></div>
	<div class="fItem"><img name="statusImage" src="greenLight.png" /></div>
	</form>
</div>


<div style="clear:both;"><p><strong>Connection Monitor</strong><br />
If your connection is active, the light should be green and the search button should be enabled, but if you connection isn't active, the light will turn red and the search button will be disabled.</p></div>

</body>
</html>
